/* 
 * File:   RoundGraph.h
 * Author: Jay Sprenkle
 *
 * Created on October 11, 2012
 */
#ifndef ROUNDGRAPH_H
#define	ROUNDGRAPH_H

#include <QObject>
#include <QRect>
#include <QPoint>
#include <QString>
#include <QWidget>
#include <QBrush>
#include <QFont>
#include <QPainter>
#include <QPainterPath>
#include <QApplication>

namespace UI
{
   class RoundGraph
      : public QWidget
   {
      Q_OBJECT
      Q_PROPERTY( QColor Color READ getColor WRITE setColor )
      Q_PROPERTY( qreal Alpha READ getAlpha WRITE setAlpha )
      Q_PROPERTY( int GraphWidth READ getGraphWidth WRITE setGraphWidth )
      Q_PROPERTY( float StartAngle READ getStartAngle WRITE setStartAngle )
      Q_PROPERTY( float SpanAngle READ getSpanAngle WRITE setSpanAngle )
      Q_PROPERTY( float Value READ getValue WRITE setValue )
      Q_PROPERTY( QColor BackgroundColor READ getBackgroundColor WRITE setBackgroundColor )
      Q_PROPERTY( qreal BackgroundAlpha READ getBackgroundAlpha WRITE setBackgroundAlpha )

   public:
      RoundGraph( QWidget* parent, Qt::WindowFlags f = 0 );

      void paintEvent( QPaintEvent* event );

      // <editor-fold defaultstate="collapsed" desc="Value Property">
   public:
      /**
       * returns the Graph Value as a ratio (0.0 - 1.0)
       * The graph is drawn in a clockwise direction
       * @return
       */
      float getValue();
      /**
       * Sets the Graph Value
       * @param a
       */
      void setValue( const float a );

   protected:
      float m_Value;
      // </editor-fold>

      // <editor-fold defaultstate="collapsed" desc="StartAngle Property">
   public:
      /**
       * returns the size of the Graph StartAngle in degrees
       * @return
       */
      float getStartAngle();
      /**
       * Sets the size of the Graph StartAngle in degrees
       * @param a
       */
      void setStartAngle( const float a );

   protected:
      float m_StartAngle;
      // </editor-fold>

      // <editor-fold defaultstate="collapsed" desc="SpanAngle Property">
   public:
      /**
       * returns the size of the Graph SpanAngle in degrees
       * @return
       */
      float getSpanAngle();
      /**
       * Sets the size of the Graph SpanAngle in degrees
       * @param a
       */
      void setSpanAngle( const float a );

   protected:
      float m_SpanAngle;
      // </editor-fold>

      // <editor-fold defaultstate="collapsed" desc="GraphWidth Property">
   public:
      /**
       * returns the Width of the graph
       * @return
       */
      int getGraphWidth();
      /**
       * Sets the Width of the graph
       * @param a
       */
      void setGraphWidth( const int a );

   protected:
      int            m_CircleWidth;
      // </editor-fold>

      // <editor-fold defaultstate="collapsed" desc="Color">
   public:
      /**
       * returns current graph color
       * @return
       */
      QColor getColor();
      /**
       * sets graph color
       * @param a
       */
      void setColor( const QColor& a );
   protected:
      QColor m_Color;
      // </editor-fold>

      // <editor-fold defaultstate="collapsed" desc="Alpha">
   public:
      /**
       * return alpha value for graph
       * @return
       */
      qreal getAlpha( );
      /**
       * set alpha value for graph
       * @param a
       */
      void setAlpha( const qreal a );
   protected:
      qreal m_Alpha;
      // </editor-fold>

      // <editor-fold defaultstate="collapsed" desc="BackgroundColor">
   public:
      /**
       * returns current graph Background color
       * @return
       */
      QColor getBackgroundColor();
      /**
       * sets graph Background color
       * @param a
       */
      void setBackgroundColor( const QColor& a );
   protected:
      QColor m_BackgroundColor;
      // </editor-fold>

      // <editor-fold defaultstate="collapsed" desc="BackgroundAlpha">
   public:
      /**
       * return Background alpha value for graph
       * @return
       */
      qreal getBackgroundAlpha();
      /**
       * set Background alpha value for graph
       * @param a
       */
      void setBackgroundAlpha( const qreal a );
   protected:
      qreal m_BackgroundAlpha;
      // </editor-fold>

   protected:
      int32_t        m_CircleWidth2;
      int32_t        m_TotalSpan;

      QPen           m_Pen;
      QPen           m_BackgroundPen;
      QPen           m_PenThin;
      QBrush         m_NoBrush;
   };
}
#endif
